package com.example.demo.controller;

import com.example.demo.controller.bean.Result;
import com.example.demo.mapper.entity.AdvertiserView;
import com.example.demo.mapper.entity.StudentTask;
import com.example.demo.mapper.entity.StudentTaskView;
import com.example.demo.service.StudentTaskManageService;
import com.example.demo.utils.PageBo;
import com.example.demo.utils.PageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("studentTaskManage")
@Api(value = "学生任务进度管理接口", tags = {"学生任务进度管理接口"})
@RestController
@Slf4j
public class StudentTaskManageController {
    @Autowired
    private StudentTaskManageService service;

    //1为拍照打卡 2为扫描二维码 3为摄像头识别 4为答题类任务
    @ResponseBody
    @ApiOperation(value = "获取学生拍照打卡任务列表接口")
    @RequestMapping(value = "getStudentPicTaskList", method = {RequestMethod.POST})
    public Result<PageVo<StudentTaskView>> getStudentTaskList(@RequestBody PageBo pageBo) {
        PageVo<StudentTaskView> list = service.getStudentPicTaskList(pageBo);
        return Result.ok(list);
    }

    @ResponseBody
    @ApiOperation(value = "获取学生扫描二维码任务列表接口")
    @RequestMapping(value = "getStudentQRTaskList", method = {RequestMethod.POST})
    public Result<PageVo<StudentTaskView>> getStudentQRTaskList(@RequestBody PageBo pageBo) {
        PageVo<StudentTaskView> list = service.getStudentQRTaskList(pageBo);
        return Result.ok(list);
    }

    @ResponseBody
    @ApiOperation(value = "获取学生摄像头识别任务列表接口")
    @RequestMapping(value = "getStudentCameraTaskList", method = {RequestMethod.POST})
    public Result<PageVo<StudentTaskView>> getStudentCameraTaskList(@RequestBody PageBo pageBo) {
        PageVo<StudentTaskView> list = service.getStudentCameraTaskList(pageBo);
        return Result.ok(list);
    }

    @ResponseBody
    @ApiOperation(value = "获取学生答题类任务任务列表接口")
    @RequestMapping(value = "getStudentQuizTaskList", method = {RequestMethod.POST})
    public Result<PageVo<StudentTaskView>> getStudentQuizTaskList(@RequestBody PageBo pageBo) {
        PageVo<StudentTaskView> list = service.getStudentQuizTaskList(pageBo);
        return Result.ok(list);
    }
    @ResponseBody
    @ApiOperation(value = "搜索学生任务接口")
    @RequestMapping(value = "searchStudentTask", method = {RequestMethod.POST})
    public Result<PageVo<StudentTaskView>> searchStudentTask(@RequestBody StudentTaskView request) {
        PageBo pageBo = new PageBo();
        pageBo.setPageNum(request.getPageNum());
        pageBo.setPageSize(request.getPageSize());

        PageVo<StudentTaskView> logs = service.searchStudentTask(request, pageBo);
        return Result.ok(logs);

    }
    @ResponseBody
    @ApiOperation("修改学生任务完成情况接口")
    @RequestMapping(value = "updateStudentTask", method = {RequestMethod.POST})
    public Result<String> updateStudentTask(@RequestBody StudentTask request) {
        return service.updateStudentTask(request);
    }

    @ResponseBody
    @ApiOperation("学生任务详情显示接口")
    @RequestMapping(value = "EdutaskDetails/{id}")
    public Result<List<StudentTaskView>> getEdutaskDetails(@PathVariable("id")int id){
        List<StudentTaskView> list = service.getEdutaskDetails(id);
        return Result.ok(list);
    }


}
